<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%@ include file="../../common/jsp/sheetHeader.jsp" %>
<script>
	$(document).ready(function() {
		//sheet 초기화  
		createIBSheet2(document.getElementById("viewArea"),"mySheet","100%","400px");
		
		var cfg = {SearchMode:smLazyLoad,Page:30};
		var headers = [
			{Text:"번호|선택|이름|정보1|정보2|정보3|정보4", Align:"Center"}
		];
		var info = {Sort:1,ColMove:1,ColResize:1,HeaderCheck:0};
		var cols = [
			{Type:"int", Width:30},
			{Type:"Combo", Width:130, ComboText:"삼성|LG"},
			{Type:"Combo", Width:100,SaveName:"NAME"},
			{Type:"Text", Width:80,Edit:true,SaveName:"A"},
			{Type:"Text", Width:85,SaveName:"B"},
			{Type:"Text", Width:85,SaveName:"C"},
			{Type:"Text", Width:85,SaveName:"D"},
		];

		mySheet.SetConfig(cfg);
		mySheet.InitHeaders(headers,info);
		mySheet.InitColumns(cols);

		mySheet.FitColWidth();
	});
	
	var ssInfo = {"ComboCode":"S3|S4|S5","ComboText":"갤럭시S3|갤럭시S4|갤럭시S5"};
	var lgInfo = {"ComboCode":"L1|L2|L3","ComboText":"옵티머스|G2|G3"};
	
	/*Sheet 각종 처리*/
	function doAction(sAction) {
		
		switch(sAction) {
			case "search":		//조회
				mySheet.DoSearch("./data/sheet_data2.xml");
				break;
				
			case "insert":
				var row = mySheet.DataInsert();
				mySheet.SetCellValue(row, 0, row);
				mySheet.CellComboItem(row, 2, ssInfo);
		    	break;
		    
// 			case "duprows":
// 				var duprows = mySheet.ColValueDupRows("NAME|A");
// 				alert(duprows);
// 		    	break;
		}
	}
	
	function mySheet_OnChange(Row, Col, Value) {
		
		if (Col == 1) {
			switch(Value) {
				case "삼성":
					mySheet.CellComboItem(Row, 2, ssInfo);
					break;
				case "LG":
					mySheet.CellComboItem(Row, 2, lgInfo);
					break;
			}
		}
		
		if (Col == 2) {
			switch(Value) {
				case "S3":
					mySheet.SetCellValue(Row, Col+1, "31");
					mySheet.SetCellValue(Row, Col+2, "32");
					mySheet.SetCellValue(Row, Col+3, "33");
					mySheet.SetCellValue(Row, Col+4, "34");
					break;
				case "S4":
					mySheet.SetCellValue(Row, Col+1, "41");
					mySheet.SetCellValue(Row, Col+2, "42");
					mySheet.SetCellValue(Row, Col+3, "43");
					mySheet.SetCellValue(Row, Col+4, "44");
					break;
				case "S5":
					mySheet.SetCellValue(Row, Col+1, "51");
					mySheet.SetCellValue(Row, Col+2, "52");
					mySheet.SetCellValue(Row, Col+3, "53");
					mySheet.SetCellValue(Row, Col+4, "54");
					break;
				case "L1":
					mySheet.SetCellValue(Row, Col+1, "101");
					mySheet.SetCellValue(Row, Col+2, "102");
					mySheet.SetCellValue(Row, Col+3, "103");
					mySheet.SetCellValue(Row, Col+4, "104");
					break;
				case "L2":
					mySheet.SetCellValue(Row, Col+1, "121");
					mySheet.SetCellValue(Row, Col+2, "122");
					mySheet.SetCellValue(Row, Col+3, "123");
					mySheet.SetCellValue(Row, Col+4, "124");
					break;
				case "L3":
					mySheet.SetCellValue(Row, Col+1, "141");
					mySheet.SetCellValue(Row, Col+2, "142");
					mySheet.SetCellValue(Row, Col+3, "143");
					mySheet.SetCellValue(Row, Col+4, "144");
					break;
			}
		}
	}
</script>
<title>콤보 내용 변경 예제</title>
</head>
<body>
<div id="main">
	<div id="title">콤보 내용 변경 예제</div>
	<div id="desc">
		첫번째 콤보박스의 값에 따라 두번째 콤보박스에서 선택할 수 있는 값이 변경된다.
	</div>
	<br>
	<input type="button" value="신규" onClick="doAction('insert');" />
	<br>&nbsp;
	<div id="viewArea"></div>
</div>
</body>
</html>